﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using ERP_RORZE_PERMISSION.Base;
using ERP_RORZE_SYSTEM;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using ERP_RORZE_PERMISSION.Base;
using ERP_RORZE_PERMISSION.Forms;

namespace ERP_RORZE_DLL.BasicList
{
    public partial class BasicListLeftPanel : UserControl
    {
        private Permission role;
        
        public BasicListLeftPanel()
        {
            InitializeComponent();
            this.role = new Permission();
            ShowHideLink();
        }

        ///////////////////////////////////////////
        /// Check role
        ///////////////////////////////////////////
        private void ShowHideLink()
        {
            if (role.Is_Login())
            {
                //if (role.HasNotRight(PermissionConstants.Functions.Tab.System))
                //    systemTab.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Country))
                    navCountry.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Group))
                    navGroup.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Staff))
                    navStaff.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Maker))
                    navMaker.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Supplier))
                    navSupplier.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Part))
                    navPart.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.UnitExchange))
                    navUnitExchange.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.PartClass))
                    navPartClass.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Unit))
                    navUnit.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.ShipTo))
                    navShipTo.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Fuctions))
                    navOptions.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Permission))
                    navPermission.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Users))
                    navUsers.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.UserGroups))
                    navUserGroup.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.BankAccount))
                    navBankAccount.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Currency))
                    navCurrency.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.ExchangeRate))
                    navExchangeRate.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Customer))
                    navCustomer.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Payment))
                    navPayment.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Comp))
                    navComp.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Kosei))
                    navKosei.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.IQ))
                    navIQ.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.DeliveryTerm))
                    navDeliveryTerm.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.General.Transport))
                    navTransport.Visible = false;
                /*
                if (role.HasNotRight(PermissionConstants.Functions.General.Section))
                    navSection.Visible = false; */

                //Product and Tool Cutting
                if (role.HasNotRight(PermissionConstants.Functions.Product.Work))
                    navWork.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Product.Jigs))
                    navJigs.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.Product.Expence))
                    navExpence.Visible = false;
                
                if (role.HasNotRight(PermissionConstants.Functions.Product.Options))
                    navOption.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.Frequency))
                    navFrequency.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.Maker))
                    navMaker333.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.Mistake))
                    navMistake.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.ProcessStatus))
                    navProcessStatus.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.Rotate))
                    navRotate.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.Supplier))
                    navSupplier333.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.ToolGroups))
                    navToolGroup.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.Tools))
                    navTool.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.ToolStatus))
                    navToolStatus.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.Kind))
                    navKind.Visible = false;

                if (role.HasNotRight(PermissionConstants.Functions.ToolCutting.Rate))
                    navRate.Visible = false; 
            }
            else
            {
                foreach (Control c in this.Controls)
                {
                    if (c is DevExpress.XtraNavBar.NavBarControl)
                    {
                        foreach (DevExpress.XtraNavBar.NavBarItem sub_c in c.Controls) {
                            ((DevExpress.XtraNavBar.NavBarItem)sub_c).Enabled = false;
                        }
                    }
                }
            }
        } 
    }
}
